home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / f2c / may_5_92.lha / f2c.VMay_5_1992 / libF77 / pow_ri.c < prev    next >
C/C++ Source or Header  |  1992-05-07  |  319b  |  37 lines

  1. #include "f2c.h"
  2.  
  3. double pow_ri(ap, bp)
  4. real *ap;
  5. integer *bp;
  6. {
  7. double pow, x;
  8. integer n;
  9.  
  10. pow = 1;
  11. x = *ap;
  12. n = *bp;
  13.  
  14. if(n != 0)
  15.     {
  16.     if(n < 0)
  17.         {
  18.         if(x == 0)
  19.             {
  20.             return(pow);
  21.             }
  22.         n = -n;
  23.         x = 1/x;
  24.         }
  25.     for( ; ; )
  26.         {
  27.         if(n & 01)
  28.             pow *= x;
  29.         if(n >>= 1)
  30.             x *= x;
  31.         else
  32.             break;
  33.         }
  34.     }
  35. return(pow);
  36. }
  37.